﻿using System.Linq;
using System;
using System.Collections;
using System.Collections.Generic;

namespace tomenglertde.SetupProject.Tools
{
    public sealed class StringEnumerator : IEnumerator<string>
    {
        private readonly IEnumerator _inner;

        public StringEnumerator(IEnumerator source)
        {
            _inner = source;
        }

        public string Current
        {
            get
            {
                return ((string)_inner.Current).Trim();
            }
        }

        public void Dispose()
        {
            var obj = _inner as IDisposable;
            if (obj != null)
                obj.Dispose();
        }

        object IEnumerator.Current
        {
            get
            {
                return Current;
            }
        }

        public bool MoveNext()
        {
            if (_inner.MoveNext())
            {
                LineNumber += 1;
                return true;
            }

            return false;
        }

        public void Reset()
        {
            _inner.Reset();
            LineNumber = 0;
        }

        public int LineNumber
        {
            get;
            private set;
        }
    }
}
